const cachePrefix = 'bamboo_'

const cache = {}

cache.get = function(key){	
	key = cachePrefix+key
	let _cacheData = uni.getStorageSync(key)
	let curTime = (new Date()).getTime()
	if(_cacheData['expireTime'] < curTime){
		return false
	}
	return _cacheData['data']
}
cache.put = function(key,data,expireTime = 15){
	key = cachePrefix+key
	if(expireTime < 1){
		expireTime = 100000000;
	}
	return uni.setStorageSync(key,{
		"data":data,
		"refresh":1,
		"expireTime":(new Date()).getTime()+expireTime*60*1000
	})
}
cache.remove = function(key){
	key = cachePrefix+key
	return uni.removeStorageSync(key)
}


export default cache
